//========================================================================
//  SE5 Research - Captain Kwok's Balance Mod v125+
//========================================================================
//
// Balance Mod Changes:
// --------------------

// v1.29 Fixed   - AI players would get stuck research Unit Weapon Mounts Level 6 (doesn't exist)
//       Fixed   - Error that prevented the AI from researching some tech areas like Weapon Mounts in low tech starts
// v1.27 Changed - Races that don't use normal shields won't research them
// v1.26 Added   - Added Fx[Give_Research_Boost] for AI game villains to make preferential research gains
// v1.25 Changed - Updated for unit tech level changes in v125
//       Changed - Updated for other tech area changes
// v1.23 Fixed   - Some tech area level requirements were incorrectly referenced
//       Changed - Removed some tech level checks that were not necessary
//       Fixed   - Psychic and Temporal technology had additional levels referenced
//       Changed - Some AI players will utilize ruin or other unique technologies
// v1.21 Fixed   - Some maximum tech levels were incorrect (Advanced Military Science, Medical Treatment)
// v1.20 Changed - Updated tech area names/levels based on tech tree changes
// v1.19 Changed - Move up some tech levels to be researched earlier
//       Fixed   - The AI would attempt to research some tech areas beyond their maximum level (v1.19g)
//       Added   - More conditions for prioritizing certain cultural tech areas (v1.19g)
//       Fixed   - AI empires with 0 research points would attempt to add research items (v1.19h)
// v1.15 Changed - Updated research pathing for tech tree changes
//       Changed - AI will immediately prioritize certain tech areas depending on need
//       Fixed   - AI wasn't adding some weapon tech areas to its research list
//       Fixed   - AI players were sometimes research tech areas that were already maxed out
// v1.10 Fixed   - Errors in maximum tech levels for some tech areas
//       Changed - Updated tech area requirements for some items
//       Changed - AI players will not research items they can't use
//       Changed - Improved AI's research pathing
// v1.09 Changed - Improved the AI's ability to add multiple projects from one category in a turn
// v1.07 Removed - Tech area calls for extra components, Weapon Platform Weapons
// v1.06 Changed - Research Minister will not be active if AI is at max tech
// v1.05 Changed - Some corrections for changes to tech tree
//       Added   - Priority values for tech areas to research
// v1.04 Changed - Some more small updates to max tech levels
// v1.03 Changed - A few updates to max tech levels
// v1.00 Changed - Added conditional statements for Bombardment Weapons and Warheads
//       Updated - Prerequisites for some tech areas
// v0.99 Changed - Added more conditional statements for some tech areas
//       Changed - Commented out some more techs the AI doesn't really use
// v0.97 Changed - A few minor tweaks to AI researching pathing
// v0.94 Fixed   - Corrected error with addition of wanted tech areas
// v0.93 Changed - Re-organized the arrangement of tech areas to improve the AI research pathway
// v0.90 Fixed   - Added fix from SE:V v1.07 to Fx[Add_Tech_Area] to stop the AI from adding techs they don't have access to
// v0.72 Updated - Tech area prerequisites in Fx[Get_Required_Techs_For_Tech] for Balance Mod
//
// Balance Mod To-do List:
// -----------------------
// - 
//
// Script Function Requests:
// -------------------------
// - Sys_Set_Tech_Area_Level(tech_id, new_tech_level) : boolean

//------------------------------------------------------------------------
// Global Variables
//------------------------------------------------------------------------
globalvars

  lng_Research_Age_Max_Level:          long

endglobalvars

//------------------------------------------------------------------------
// Forward Declarations
//------------------------------------------------------------------------
deffunc

function Add_Research_Items returns boolean
params
end

function Add_Wanted_Tech_Areas_For_Designs returns boolean
params
  max_level:                 long
end

function Add_Tech_Area returns boolean
params
  tech_name:                 string
  max_level:                 long
  priority_level:            long
  add_tech_area:             boolean
end

function Add_Tech_Area_By_ID returns boolean
params
  tech_id:                   long
end

function Get_Tech_Group_Spending_Pct returns long
params
  tech_id:                   long
end

function Set_Tech_Group_Spending_Pct returns boolean
params
  tech_id:                   long
  spending_amt:              long
end

function Get_Required_Techs_For_Tech returns boolean
params
  src_tech_name:             string
  tech_name:                 string byref
  tech_level:                long byref
end

function Give_Research_Boost returns boolean
params
end

enddeffunc

//------------------------------------------------------------------------
// AI_Research
//------------------------------------------------------------------------
function AI_Research returns boolean
vars
  research_pts:              long
begin

  // Get our current research points
  set research_pts := Sys_Get_Empire_Current_Points(sys_long_Player_ID, POINT_TYPE_RESEARCH)

  if Sys_Using_AI_Minister(sys_long_Player_ID, "Research") and (not bool_Race_At_Max_Tech) then
    // Debug output
    call Sys_Debug_Print("Research", "---------")
    call Sys_Debug_Print("Research", "Research:")
    // Add research items
    if (research_pts > 0) then
      call Add_Research_Items()
    else
      // Debug output
      call Sys_Debug_Print("Research", "  - No research points")
    endif
    // Special routine for game villains to receive accelerated research benefits
    if Sys_Are_We_Computer_Player(sys_long_Player_ID) and (lng_AI_Villain_Status = AI_CATEGORY_VILLAIN) then
      call Give_Research_Boost()
    endif
    // Save design upgrade modifier
    call Sys_Set_AI_Storage_Long(sys_long_Player_ID, 1, 8, lng_AI_Design_Upgrade_Modifier)
  endif

end

//------------------------------------------------------------------------
// Add_Research_Items
//------------------------------------------------------------------------
function Add_Research_Items returns boolean
params
vars
  tech_id:                   long
  tech_level:                long
  num_tech_areas:            long
  tech_index:                long
  spending_pct:              long
  unspent_pct:               long
  tech_research_count:       long
  tech_spending_pct:         long
  tech_name:                 string
  tech_group_name:           string
  our_tech_level:            long
  target_tech_level:         long
begin

  // Clear our previous research spending
  call Sys_Clear_Empire_Research_All_Tech_Area_Spending(sys_long_Player_ID)

  // Prioritize our research if we are not connected
  if (Sys_Get_AI_State(sys_long_Player_ID) = AI_STATE_NOT_CONNECTED) then
    call Add_Tech_Area("Astrophysics", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Stellar Manipulation", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Warp Point Manipulation", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Applied Research", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Rock Planet Colonization", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Ice Planet Colonization", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Gas Giant Colonization", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif

  // Research Medical Treatment right away if you cannot cure a plague
  if (bool_Race_cannot_Cure_Plague) then
    call Add_Tech_Area("Medical Treatment", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif

  // Prioritize Repair if we are at war
  if (lng_AI_Num_Of_Wars > 0) or (lng_AI_Num_Of_Enemies > 2) then
    call Add_Tech_Area("Repair", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif

  // Obtain Phased Shields if our enemies using phased weapons
  if (bool_Race_Uses_Normal_Shields) then
    if (bool_Enemy_Uses_Skip_Shield_Weapons) and (not Is_Tech_Area_Available("Shields", 11)) then
      set our_tech_level := Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, Sys_Get_Tech_ID("Shields"))
      // Increase the pace if we're far off the requirement for Phased-Shields
      if (our_tech_level <= 6) then
        set target_tech_level := our_tech_level + 2
      else
        set target_tech_level := our_tech_level + 1
      endif
      call Add_Tech_Area("Shields", target_tech_level, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
    endif
  endif

  // Prioritize sensors
  if (bool_Enemy_Ships_Have_Better_Sensors) then
    set our_tech_level := Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, Sys_Get_Tech_ID("Sensors"))
    set target_tech_level := our_tech_level + 1
    call Add_Tech_Area("Basic Sensors", target_tech_level, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif

  // Prioritize the matching extraction technology if we are low in a resource
  if (bool_Race_Minerals_Low) then
    set our_tech_level := Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, Sys_Get_Tech_ID("Minerals Extraction"))
    set target_tech_level := Sys_Min_Long(11, our_tech_level + 1)
    call Add_Tech_Area("Minerals Extraction", target_tech_level, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif
  if (bool_Race_Organics_Low) then
    set our_tech_level := Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, Sys_Get_Tech_ID("Organics Extraction"))
    set target_tech_level := Sys_Min_Long(11, our_tech_level + 1)
    call Add_Tech_Area("Organics Extraction", target_tech_level, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif
  If (bool_Race_Radioactives_Low) then
    set our_tech_level := Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, Sys_Get_Tech_ID("Radioactives Extraction"))
    set target_tech_level := Sys_Min_Long(11, our_tech_level + 1)
    call Add_Tech_Area("Radioactives Extraction", target_tech_level, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif

  // Prioritize Economics if maintenance costs are high
  if (bool_Race_Maintenance_High) then
    call Add_Tech_Area("Economics", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif

  // Prioritize Education if far behind on research
  if (bool_Enemy_Ahead_In_Research) or (bool_Enemy_Far_Ahead_In_Research) then
    call Add_Tech_Area("Education", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif

  // Prioritize Ethics if far behind on research
  if (bool_Enemy_Ahead_In_Intel) or (bool_Enemy_Far_Ahead_In_Intel) or (bool_Enemy_Intel_Overload) then
    call Add_Tech_Area("Ethics", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
  endif

  // 1st Age
  set lng_Research_Age_Max_Level := 3

  // 1st Age - Cultural Advancement Tech Areas
  call Add_Tech_Area("Cultural Studies", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)

  // 1st Age Theoretical Science Tech Areas
  call Add_Tech_Area("Physics", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Military Science", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Construction", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)

  // 1st Age - Applied Science Tech Areas
  call Add_Tech_Area("Crystalline Technology", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Sensors", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Armor", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Ion Engines", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Small Ship Construction", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Small Ship Construction", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Small Base Construction", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Shields", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Armor", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Ion Engines", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Defense Systems", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Repair", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Troops", 2, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Troops)
  call Add_Tech_Area("Fighters", 2, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Fighters)
  call Add_Tech_Area("Mines", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)
  call Add_Tech_Area("Small Ship Construction", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Sabotage - Ships & Fleets", 1, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 1, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
  endif

  // 1st Age - Weapon Tech Areas
  call Add_Wanted_Tech_Areas_For_Designs(1)

  // 2nd Age
  set lng_Research_Age_Max_Level := 6

  // 2nd Age - Cultural Achievement Tech Areas
  call Add_Tech_Area("Economics", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Education", 2, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Recreation", 2, RESEARCH_PRIORITY_LOW, TRUE)

  // 2nd Age - Theoretical Science Tech Areas
  call Add_Tech_Area("Psychology", 1, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Physics", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Military Science", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Astrophysics", 2, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Biology", 2, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Chemistry", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Industry", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Xenoarchaeology", 1, RESEARCH_PRIORITY_LOW, TRUE)

  // 2nd Age - Applied Science Tech Areas
  call Add_Tech_Area("Crystalline Technology", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Medium Ship Construction", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Small Ship Construction", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Small Base Construction", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Armor", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Contra-Terrene Engines", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Sensors", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Stellar Harnessing", 1, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Crystalline Technology", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Space Yards", 2, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Repair", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Resupply", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Medical Treatment", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Small Ship Construction", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Resupply", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Defense Systems", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Storage", 2, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Cargo", 2, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Resupply", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Defense Systems", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Armor", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)

  call Add_Tech_Area("Applied Research", 2, RESEARCH_PRIORITY_HIGH, not bool_Race_At_Max_Tech)
  call Add_Tech_Area("Advanced Military Science", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Applied Political Science", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Computers", 1, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Robotics", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Neural Computer Interface", 1, RESEARCH_PRIORITY_MEDIUM, bool_Race_Uses_Combat_Best_Experience)

  call Add_Tech_Area("Medium Ship Construction", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Contra-Terrene Engines", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Stellar Harnessing", 2, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Medium Ship Construction", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Shields", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Defense Systems", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Resupply", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Ship Weapon Mounts", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Medium Ship Construction", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Minerals Extraction", 2, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 1, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 1, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Troops", 3, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Troops)
  call Add_Tech_Area("Fighters", 3, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Fighters)
  call Add_Tech_Area("Satellites", 2, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Satellites)
  call Add_Tech_Area("Weapon Platforms", 2, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Weapon_Platforms)
  call Add_Tech_Area("Drones", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Drones)

  call Add_Tech_Area("Medium Ship Construction", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Shields", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Armor", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Sensors", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Rock Planet Colonization", 1, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Ice Planet Colonization", 1, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Gas Giant Colonization", 1, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Crystalline Technology", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Advanced Military Science", 2, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Robotics", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Space Yards", 3, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Repair", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Vehicle Systems", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Resupply", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Armor", 7, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Ships & Fleets", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 1, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 2, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Planets & Colonies", 1, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
  endif

  // 2nd Age - Weapon Tech Areas
  call Add_Wanted_Tech_Areas_For_Designs(3)

  // 3rd Age
  set lng_Research_Age_Max_Level := 9

  // 3rd Age - Cultural Achievement Tech Areas
  call Add_Tech_Area("Civics", 2, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Conservation", 2, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Economics", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Education", 4, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Engineering", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Environment", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Ethics", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Logistics", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Recreation", 4, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Military", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Diplomacy", 4, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Sociology", 2, RESEARCH_PRIORITY_LOW, TRUE)

  // 3rd Age - Theoretical Tech Areas
  call Add_Tech_Area("Physics", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Astrophysics", 3, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Chemistry", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Construction", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Industry", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planetary Engineering", 1, RESEARCH_PRIORITY_LOW, TRUE)

  // 3rd Age - Applied Science Tech Areas
  call Add_Tech_Area("Crystalline Technology", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Applied Research", 3, RESEARCH_PRIORITY_HIGH, not bool_Race_At_Max_Tech)
  call Add_Tech_Area("Advanced Military Science", 3, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Applied Political Science", 2, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Shields", 4, RESEARCH_PRIORITY_CRITICAL,bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Armor", 8, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Sensors", 8, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Scanners", 1, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Stellar Harnessing", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Resupply", 7, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Gravitational Manipulation", 1, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Medium Ship Construction", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Troops", 4, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Troops)
  call Add_Tech_Area("Fighters", 4, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Fighters)
  call Add_Tech_Area("Drones", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Drones)
  call Add_Tech_Area("Warheads", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)
  call Add_Tech_Area("Mines", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)

  call Add_Tech_Area("Shields", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Armor", 9, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Planetary Defenses", 1, RESEARCH_PRIORITY_CRITICAL, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))
  call Add_Tech_Area("Massive Planetary Shielding", 1, RESEARCH_PRIORITY_CRITICAL, Is_Tech_Area_Available("Massive Planetary Shielding", 1))

  call Add_Tech_Area("Minerals Extraction", 3, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 1, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Crystalline Technology", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Large Ship Construction", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Vehicle Systems", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Contra-Terrene Engines", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Shields", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Sensors", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Armor", 10, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Defense Systems", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Scanners", 2, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Space Yards", 4, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Repair", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planetary Defenses", 2, RESEARCH_PRIORITY_LOW, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))

  call Add_Tech_Area("Minerals Extraction", 4, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 2, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Centralized Computer Systems", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Storage", 3, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Cargo", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Resupply", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Sensors", 12, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Minerals Extraction", 5, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 5, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 3, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Resource Manipulation", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Cloaking", 1, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)
  call Add_Tech_Area("Scanners", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Armor", 11, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)

  call Add_Tech_Area("Applied Research", 4, RESEARCH_PRIORITY_HIGH, not bool_Race_At_Max_Tech)

  call Add_Tech_Area("Minerals Extraction", 6, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 6, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 4, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Crystalline Technology", 7, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 7, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 7, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 7, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 7, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 7, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Cloaking", 2, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)
  call Add_Tech_Area("Computers", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Centralized Computer Systems", 2, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Neural Computer Interface", 2, RESEARCH_PRIORITY_MEDIUM, bool_Race_Uses_Combat_Best_Experience)

  call Add_Tech_Area("Applied Research", 5, RESEARCH_PRIORITY_HIGH, not bool_Race_At_Max_Tech)
  call Add_Tech_Area("Applied Political Science", 3, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Planet Utilization", 5, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Troops", 5, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Troops)
  call Add_Tech_Area("Fighters", 5, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Fighters)
  call Add_Tech_Area("Satellites", 3, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Satellites)
  call Add_Tech_Area("Weapon Platforms", 3, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Weapon_Platforms)
  call Add_Tech_Area("Drones", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Drones)
  call Add_Tech_Area("Warheads", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)
  call Add_Tech_Area("Mines", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)

  call Add_Tech_Area("Space Yards", 5, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Repair", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planetary Defenses", 3, RESEARCH_PRIORITY_MEDIUM, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))
  call Add_Tech_Area("Resupply", 9, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Medical Treatment", 4, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Stellar Harnessing", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Armor", 12, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Shields", 7, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)

  call Add_Tech_Area("Crystalline Technology", 8, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 8, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 8, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 8, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 8, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 8, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Cloaking", 3, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)
  call Add_Tech_Area("Shields", 8, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Armor", 13, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Resupply", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Cargo", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Storage", 4, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Centralized Computer Systems", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Ships & Fleets", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Empire Wide", 1, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 3, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Planets & Colonies", 2, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Empire Wide", 1, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
  endif

  call Add_Tech_Area("Space Yards", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Repair", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Medical Treatment", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Large Ship Construction", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Shields", 9, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Armor", 14, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)

  // 3rd Age - Add wanted tech areas
  call Add_Wanted_Tech_Areas_For_Designs(6)

  // 4th Age
  set lng_Research_Age_Max_Level := 12

  // Age 4 - Cultural Achievement Tech Areas
  call Add_Tech_Area("Civics", 4, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Conservation", 4, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Economics", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Education", 6, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Engineering", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Environment", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Ethics", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Logistics", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Recreation", 6, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Military", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Diplomacy", 6, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Sociology", 4, RESEARCH_PRIORITY_LOW, TRUE)

  // 4th Age - Theoretical Tech Areas
  call Add_Tech_Area("Astrophysics", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)

  // 4th Age - Applied Science Tech Areas
  call Add_Tech_Area("Crystalline Technology", 9, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 9, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 9, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 9, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 9, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 9, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Armor", 15, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Shields", 10, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Sensors", 14, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Defense Systems", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Scanners", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Planetary Defenses", 4, RESEARCH_PRIORITY_MEDIUM, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))
  call Add_Tech_Area("Massive Planetary Shielding", 2, RESEARCH_PRIORITY_MEDIUM, Is_Tech_Area_Available("Massive Planetary Shielding", 1))

  call Add_Tech_Area("Large Ship Construction", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Jacketed-Photon Engines", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Resupply", 11, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Cargo", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Storage", 5, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Robotics", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Centralized Computer Systems", 4, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Stellar Harnessing", 5, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Resource Manipulation", 4, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Space Yards", 7, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Repair", 7, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Medium Ship Construction", 7, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Troops", 6, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Troops)
  call Add_Tech_Area("Fighters", 6, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Fighters)
  call Add_Tech_Area("Warheads", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Ships & Fleets", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Empire Wide", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Political", 1, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 4, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Planets & Colonies", 3, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Empire Wide", 2, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Political", 1, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
  endif

  call Add_Tech_Area("Crystalline Technology", 10, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 10, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 10, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 10, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 10, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 10, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Large Ship Construction", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Small Base Construction", 4, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Large Base Construction", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Medium Ship Construction", 8, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Jacketed-Photon Engines", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Vehicle Systems", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Resupply", 12, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Gravitational Manipulation", 2, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Centralized Computer Systems", 5, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Robotics", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Planetary Defenses", 5, RESEARCH_PRIORITY_MEDIUM, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))
  call Add_Tech_Area("Medical Treatment", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Resource Manipulation", 5, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Minerals Extraction", 6, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 6, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 6, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Cargo", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Storage", 6, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Resupply", 13, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Armor", 16, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Shields", 11, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Sensors", 16, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Defense Systems", 7, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Scanners", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Computers", 3, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Cloaking", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)
  call Add_Tech_Area("Neural Computer Interface", 3, RESEARCH_PRIORITY_MEDIUM, bool_Race_Uses_Combat_Best_Experience)

  call Add_Tech_Area("Applied Research", 6, RESEARCH_PRIORITY_HIGH, not bool_Race_At_Max_Tech)
  call Add_Tech_Area("Advanced Military Science", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Planetary Manipulation", 2, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Crystalline Technology", 11, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 11, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 11, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 11, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 11, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 11, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Minerals Extraction", 7, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 7, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 7, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Planetary Manipulation", 4, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Space Yards", 8, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Repair", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Medical Treatment", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Shields", 12, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Sensors", 18, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Defense Systems", 8, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Large Ship Construction", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Medium Ship Construction", 9, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Cloaking", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)
  call Add_Tech_Area("Resupply", 14, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Crystalline Technology", 12, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 12, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 12, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 12, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 12, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 12, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Troops", 7, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Troops)
  call Add_Tech_Area("Fighters", 7, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Fighters)
  call Add_Tech_Area("Satellites", 4, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Satellites)
  call Add_Tech_Area("Weapon Platforms", 4, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Weapon_Platforms)
  call Add_Tech_Area("Drones", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Drones)
  call Add_Tech_Area("Warheads", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)
  call Add_Tech_Area("Mines", 4, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Ships & Fleets", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Empire Wide", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Political", 2, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 5, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Planets & Colonies", 4, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Empire Wide", 3, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Political", 2, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Cooperative Intelligence", 1, RESEARCH_PRIORITY_LOW, TRUE)
  endif

  call Add_Tech_Area("Minerals Extraction", 8, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 8, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 7, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Scanners", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)

  // 4th Age - Wanted Tech Areas
  call Add_Wanted_Tech_Areas_For_Designs(9)

  // 5th Age
  set lng_Research_Age_Max_Level := 16

  // 5th Age - Cultural Achievement Tech Areas
  call Add_Tech_Area("Civics", 6, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Conservation", 6, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Economics", 8, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Education", 8, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Engineering", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Environment", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Ethics", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Logistics", 8, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Recreation", 8, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Military", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Diplomacy", 8, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Sociology", 6, RESEARCH_PRIORITY_LOW, TRUE)

  // 5th Age - Theoretical Tech Areas Age 5
  call Add_Tech_Area("Astrophysics", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)

  // 5th Age - Applied Science Tech Areas
  call Add_Tech_Area("Crystalline Technology", 13, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 13, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 13, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 13, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 13, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 13, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Shields", 13, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Sensors", 20, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Defense Systems", 9, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Scanners", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Armor", 17, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)

  call Add_Tech_Area("Large Ship Construction", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Space Yards", 9, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Repair", 9, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Resupply", 15, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Gravitational Manipulation", 3, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Cargo", 7, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Storage", 7, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Robotics", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Resource Manipulation", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Large Ship Construction", 7, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Small Base Construction", 5, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Large Ship Construction", 8, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Jacketed-Photon Engines", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Cloaking", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)

  call Add_Tech_Area("Robotics", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Planetary Defenses", 6, RESEARCH_PRIORITY_MEDIUM, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))
  call Add_Tech_Area("Stellar Manipulation", 3, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Minerals Extraction", 9, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 9, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 9, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 8, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Space Yards", 10, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Repair", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Computers", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Resupply", 16, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Minerals Extraction", 10, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 10, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Cloaking", 7, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)
  call Add_Tech_Area("Quantum Engines", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Vehicle Systems", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Cloaking", 8, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)
  call Add_Tech_Area("Warp Point Manipulation", 1, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Robotics", 7, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Defense Systems", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Scanners", 7, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Planet Utilization", 9, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Crystalline Technology", 14, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 14, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 14, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 14, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 14, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 14, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Troops", 8, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Troops)
  call Add_Tech_Area("Warheads", 6, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)

  call Add_Tech_Area("Quantum Engines", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Armor", 18, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Shields", 14, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Ships & Fleets", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Empire Wide", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Political", 3, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 6, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Planets & Colonies", 5, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Empire Wide", 4, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Political", 3, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Cooperative Intelligence", 2, RESEARCH_PRIORITY_LOW, TRUE)
  endif

  call Add_Tech_Area("Planetary Defenses", 7, RESEARCH_PRIORITY_MEDIUM, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))

  call Add_Tech_Area("Warp Point Manipulation", 2, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Cloaking", 9, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)

  call Add_Tech_Area("Crystalline Technology", 15, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Interdimensional Technology", 15, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Interdimensional_Tech)
  call Add_Tech_Area("Organic Technology", 15, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Psychic Technology", 15, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Psychic_Tech)
  call Add_Tech_Area("Religious Technology", 15, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)
  call Add_Tech_Area("Temporal Technology", 15, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Temporal_Tech)

  call Add_Tech_Area("Planetary Manipulation", 6, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Warp Point Manipulation", 3, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Planet Utilization", 10, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Crystalline Technology", 16, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Organic Technology", 16, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Religious Technology", 16, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)

  call Add_Tech_Area("Quantum Engines", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Shields", 15, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Defense Systems", 11, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Scanners", 8, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Large Ship Construction", 9, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Large Base Construction", 2, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Quantum Engines", 4, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Baseship Construction", 1, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Cloaking", 10, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)

  call Add_Tech_Area("Cargo", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Storage", 8, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Applied Research", 8, RESEARCH_PRIORITY_HIGH, not bool_Race_At_Max_Tech)
  call Add_Tech_Area("Advanced Military Science", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Applied Political Science", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 7, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Ships & Fleets", 7, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Empire Wide", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Political", 4, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 7, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Planets & Colonies", 6, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Empire Wide", 5, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Political", 4, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Cooperative Intelligence", 3, RESEARCH_PRIORITY_LOW, TRUE)
  endif

  call Add_Tech_Area("Shields", 16, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)

  call Add_Tech_Area("Minerals Extraction", 11, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 11, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 11, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 11, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Applied Research", 9, RESEARCH_PRIORITY_HIGH, not bool_Race_At_Max_Tech)

  call Add_Tech_Area("Planetary Manipulation", 8, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Star Manipulation", 2, RESEARCH_PRIORITY_HIGH, TRUE)

  // 5th Age - Wanted tech areas for Age 5
  call Add_Wanted_Tech_Areas_For_Designs(12)

  // 6th Age
  set lng_Research_Age_Max_Level := 20

  // 6th Age - Cultural Achievement Tech Areas
  call Add_Tech_Area("Civics", 10, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Conservation", 10, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Economics", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Education", 10, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Engineering", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Environment", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Ethics", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Logistics", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Recreation", 10, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Military", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Diplomacy", 10, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Sociology", 10, RESEARCH_PRIORITY_LOW, TRUE)

  // 6th Age - Theoretical Science Tech Areas Age 6
  // None

  // Applied Science Tech Areas Age 6
  call Add_Tech_Area("Crystalline Technology", 17, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Organic Technology", 17, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Religious Technology", 17, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)

  call Add_Tech_Area("Space Yards", 11, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Repair", 11, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Cloaking", 11, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Cloaking_Devices)
  call Add_Tech_Area("Planetary Defenses", 8, RESEARCH_PRIORITY_MEDIUM, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))

  call Add_Tech_Area("Gravitational Manipulation", 4, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Resupply", 17, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Cargo", 9, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Storage", 9, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Robotics", 8, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Minerals Extraction", 12, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 12, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 12, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 12, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Resource Manipulation", 11, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Large Base Construction", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Small Base Construction", 6, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Baseship Construction", 2, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Stellar Manipulation", 3, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Troops", 9, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Troops)
  call Add_Tech_Area("Fighters", 7, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Fighters)
  call Add_Tech_Area("Satellites", 5, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Satellites)
  call Add_Tech_Area("Weapon Platforms", 5, RESEARCH_PRIORITY_HIGH, bool_Race_Uses_Weapon_Platforms)
  call Add_Tech_Area("Drones", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Drones)
  call Add_Tech_Area("Mines", 5, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Mines)

  call Add_Tech_Area("Applied Research", 10, RESEARCH_PRIORITY_HIGH, not bool_Race_At_Max_Tech)
  call Add_Tech_Area("Applied Political Science", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 8, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Ships & Fleets", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 7, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Empire Wide", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Political", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 8, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Planets & Colonies", 7, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Empire Wide", 6, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Political", 5, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Cooperative Intelligence", 4, RESEARCH_PRIORITY_LOW, TRUE)
  endif

  call Add_Tech_Area("Crystalline Technology", 18, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Organic Technology", 18, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Religious Technology", 18, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)

  call Add_Tech_Area("Quantum Engines", 5, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Baseship Construction", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Robotics", 9, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Armor", 19, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Shields", 17, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Scanners", 9, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Resupply", 18, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Planetary Defenses", 9, RESEARCH_PRIORITY_MEDIUM, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))
  call Add_Tech_Area("Massive Planetary Shielding", 3, RESEARCH_PRIORITY_MEDIUM, Is_Tech_Area_Available("Massive Planetary Shielding", 1))

  call Add_Tech_Area("Computers", 5, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Cargo", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Storage", 10, RESEARCH_PRIORITY_LOW, TRUE)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 9, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Ships & Fleets", 9, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Empire Wide", 7, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Political", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 9, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Planets & Colonies", 8, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Empire Wide", 7, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Political", 6, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Cooperative Intelligence", 5, RESEARCH_PRIORITY_LOW, TRUE)
  endif

  call Add_Tech_Area("Space Yards", 11, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Vehicle Systems", 6, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Storage", 11, RESEARCH_PRIORITY_LOW, TRUE)

  call Add_Tech_Area("Large Base Construction", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Baseship Construction", 3, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Shields", 18, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Scanners", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Resupply", 19, RESEARCH_PRIORITY_MEDIUM, TRUE)

  call Add_Tech_Area("Crystalline Technology", 19, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Organic Technology", 19, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Religious Technology", 19, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)

  call Add_Tech_Area("Armor", 20, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Armor)
  call Add_Tech_Area("Shields", 19, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)

  call Add_Tech_Area("Baseship Construction", 6, RESEARCH_PRIORITY_CRITICAL, TRUE)
  call Add_Tech_Area("Planetary Defenses", 10, RESEARCH_PRIORITY_MEDIUM, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 10, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Ships & Fleets", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 9, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Empire Wide", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Political", 7, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Ships & Fleets", 10, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Planets & Colonies", 9, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Empire Wide", 8, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Political", 7, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
  endif

  call Add_Tech_Area("Crystalline Technology", 20, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Crystalline_Tech)
  call Add_Tech_Area("Organic Technology", 20, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Organic_Tech)
  call Add_Tech_Area("Religious Technology", 20, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Religious_Tech)

  call Add_Tech_Area("Shields", 20, RESEARCH_PRIORITY_CRITICAL, bool_Race_Uses_Normal_Shields)
  call Add_Tech_Area("Scanners", 11, RESEARCH_PRIORITY_CRITICAL, TRUE)

  call Add_Tech_Area("Resupply", 20, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Cargo", 11, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planetary Defenses", 11, RESEARCH_PRIORITY_MEDIUM, not Is_Tech_Area_Available("Massive Planetary Shielding", 1))

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Intelligence Services", 11, RESEARCH_PRIORITY_CRITICAL, TRUE)
    call Add_Tech_Area("Sabotage - Planets & Colonies", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Empire Wide", 9, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Political", 8, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Planets & Colonies", 10, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Empire Wide", 9, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Political", 8, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
  endif

  call Add_Tech_Area("Minerals Extraction", 13, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 13, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 13, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 13, RESEARCH_PRIORITY_LOW, TRUE)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Sabotage - Empire Wide", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Sabotage - Political", 9, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Empire Wide", 10, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
    call Add_Tech_Area("Espionage - Political", 9, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
  endif

  call Add_Tech_Area("Warp Point Manipulation", 4, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Planetary Manipulation", 10, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Applied Research", 11, RESEARCH_PRIORITY_HIGH, not bool_Race_At_Max_Tech)

  call Add_Tech_Area("Minerals Extraction", 14, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 14, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 14, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 14, RESEARCH_PRIORITY_LOW, TRUE)

  if (bool_Intel_Is_Allowed) then
    call Add_Tech_Area("Sabotage - Political", 10, RESEARCH_PRIORITY_MEDIUM, TRUE)
    call Add_Tech_Area("Espionage - Political", 10, RESEARCH_PRIORITY_LOW, not bool_Are_We_Computer_Player)
  endif

  call Add_Tech_Area("Minerals Extraction", 15, RESEARCH_PRIORITY_HIGH, TRUE)
  call Add_Tech_Area("Organics Extraction", 15, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Radioactives Extraction", 15, RESEARCH_PRIORITY_MEDIUM, TRUE)
  call Add_Tech_Area("Planet Utilization", 15, RESEARCH_PRIORITY_LOW, TRUE)
  call Add_Tech_Area("Resource Manipulation", 15, RESEARCH_PRIORITY_HIGH, TRUE)

  call Add_Tech_Area("Warp Point Manipulation", 5, RESEARCH_PRIORITY_HIGH, TRUE)

  // 6th Age - Wanted Tech Areas
  call Add_Wanted_Tech_Areas_For_Designs(20)

  // If we have leftover research points, boost our current research spending
  set spending_pct := Sys_Get_Empire_Research_Total_Tech_Area_Spending_Pct(sys_long_Player_ID)

  // Add leftover tech points to any area we are researching
  if (spending_pct > 0) and (spending_pct < 100) then
    set unspent_pct := 100 - spending_pct
    set num_tech_areas := Sys_Get_Tech_Area_Count()
    // Check first for how many areas we are researching
    if (num_tech_areas > 0) then
      for tech_index := 1 to num_tech_areas do
        set tech_id := Sys_Get_Tech_By_Index(tech_index)
        set tech_spending_pct := Sys_Get_Empire_Research_Tech_Area_Spending_Pct(sys_long_Player_ID, tech_id)
        // Count
        if (tech_spending_pct > 0) then
          set tech_research_count := tech_research_count + 1
        endif
      endfor
      // Divide the the unspent amount amongst current research
      set unspent_pct := Sys_Divide_long(unspent_pct, tech_research_count)
    endif
    // Adjust the research spending
    if (num_tech_areas > 0) then
      for tech_index := 1 to num_tech_areas do
        set tech_id := Sys_Get_Tech_By_Index(tech_index)
        set tech_name := Sys_Get_Tech_Area_Name(tech_id)
        set tech_spending_pct := Sys_Get_Empire_Research_Tech_Area_Spending_Pct(sys_long_Player_ID, tech_id)
        set tech_group_name := Sys_Get_Tech_Area_Group(tech_id)
        // Increase the spending amount
        if (tech_spending_pct > 0) then
          call Sys_Set_Empire_Research_Tech_Area_Spending_Pct(sys_long_Player_ID, tech_id, tech_spending_pct + unspent_pct)
          // Debug output
          call Sys_Debug_Print("Research", "    - Increased " + tech_name + " spending to " Sys_Convert_Long_To_String(tech_spending_pct + unspent_pct) + "%")
        endif
      endfor
    endif
  endif

  // Research every tech area
  if (spending_pct < 100) then
    // Debug output
    call Sys_Debug_Print("Research", "  - Research added due to incomplete spending:")
    // Look through all technologies and apply research to any with levels to complete
    set num_tech_areas := Sys_Get_Tech_Area_Count()
    for tech_index := 1 to num_tech_areas do
      set tech_id := Sys_Get_Tech_By_Index(tech_index)
      call Add_Tech_Area_By_ID(tech_id)
    endfor
  endif

  return TRUE
end

//------------------------------------------------------------------------
// Add_Wanted_Tech_Areas_For_Designs
//------------------------------------------------------------------------
function Add_Wanted_Tech_Areas_For_Designs returns boolean
params
  max_level:                 long
vars
  tech_added:                boolean := FALSE
  tech_name:                 string
  tech_id:                   long
  tech_level:                long
  max_level:                 long
  list_count:                long
  list_index:                long
  tech_age_index:            long
begin

  // Common tech areas to research
  call lst_Research_Tech_Area_Name.add("Point-Defense Weapons")
  call lst_Research_Tech_Area_Max_Level.add(11)

  call lst_Research_Tech_Area_Name.add("Smaller Weapons")
  call lst_Research_Tech_Area_Max_Level.add(6)

  call lst_Research_Tech_Area_Name.add("Troop Weapons")
  call lst_Research_Tech_Area_Max_Level.add(11)

  if (bool_Race_Uses_Boarding_Ships) then
    call lst_Research_Tech_Area_Name.add("Ship Capture")
    call lst_Research_Tech_Area_Max_Level.add(11)
  endif

  if (bool_Race_Uses_Bombardment_Ships) then
    call lst_Research_Tech_Area_Name.add("Bombardment Weapons")
    call lst_Research_Tech_Area_Max_Level.add(6)
  endif

  if (bool_Race_Uses_Plague_Ships) then
    call lst_Research_Tech_Area_Name.add("Biological Weapons")
    call lst_Research_Tech_Area_Max_Level.add(11)
  endif

  if (bool_Race_Uses_Mines) or (bool_Race_Uses_Kamikaze_Ships) then
    call lst_Research_Tech_Area_Name.add("Warheads")
    call lst_Research_Tech_Area_Max_Level.add(16)
  endif

  call lst_Research_Tech_Area_Name.add("Weapon Mounts")
  call lst_Research_Tech_Area_Max_Level.add(1)

  call lst_Research_Tech_Area_Name.add("Ship Weapon Mounts")
  call lst_Research_Tech_Area_Max_Level.add(11)

  call lst_Research_Tech_Area_Name.add("Base Weapon Mounts")
  call lst_Research_Tech_Area_Max_Level.add(11)

  call lst_Research_Tech_Area_Name.add("Unit Weapon Mounts")
  call lst_Research_Tech_Area_Max_Level.add(5)

  // Add a level of each tech to our research queue
  set list_count := lst_Research_Tech_Area_Name.count()

  if (list_count > 0) and (lng_Research_Age_Max_Level > 0) then
    for tech_age_index := 1 to lng_Research_Age_Max_Level do
      for list_index := 1 to list_count do
        set tech_name := lst_Research_Tech_Area_Name.get(list_index)
        set tech_id := Sys_Get_Tech_ID(tech_name)
        set tech_level := Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, tech_id)
        set max_level := lst_Research_Tech_Area_Max_Level.get(list_index)
        // Don't try to add if we are already spending in this research area
        if (Sys_Get_Empire_Research_Tech_Area_Spending_Pct(sys_long_Player_ID, tech_id) = 0) then
          // Attempt to add the tech area to the queue if there are still levels to research
          if (tech_age_index <= max_level) and (tech_level <= lng_Research_Age_Max_Level) and (tech_level < max_level) then
            set tech_added := Add_Tech_Area(tech_name, max_level, RESEARCH_PRIORITY_CRITICAL, TRUE)
            // Debug output
            if (tech_added) then
              call Sys_Debug_Print("Research", "    - Wanted tech area for designs")
            endif
          endif
        endif
      endfor
    endfor
  endif

  return tech_added
end

//------------------------------------------------------------------------
// Add_Tech_Area
//------------------------------------------------------------------------
function Add_Tech_Area returns boolean
params
  tech_name:                 string
  max_level:                 long
  priority_level:            long
  add_tech_area:             boolean
vars
  tech_id:                   long
  tech_level:                long
  cur_spending_pts:          long
  pts_to_next_level:         long
  pts_to_spend:              long
  spending_pct:              long
  base_tech_name:            string
  base_tech_level:           long
  skip_tech_area:            boolean := FALSE
  tech_area_added:           boolean := FALSE
  tech_level_complete:       boolean := FALSE
  tech_area_complete:        boolean := FALSE
  debug_str:                 string
begin

  set tech_id := Sys_Get_Tech_ID(tech_name)
  set tech_level := Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, tech_id) 
  set tech_area_complete := Sys_Is_Empire_Research_Tech_At_Maximum(sys_long_Player_ID, tech_id)

  // Debug output
  call Sys_Debug_Print("Research", "  - " + tech_name + " (" + Sys_Convert_Long_To_String(tech_level) + ")")

  // Should we add this tech area?
  if (add_tech_area) then
    // Skip if not a priority
    if (priority_level < lng_Research_Priority_Level) then
      set skip_tech_area := TRUE
      // Debug output
      call Sys_Debug_Print("Research", "    - Skip " + tech_name + " (Prioritize other tech)")
    endif
    // Skip if the tech area is not visible
    if Sys_Is_Empire_Research_Tech_Visible(sys_long_Player_ID, tech_id) then
      // Skip if the tech area is completed
      if (tech_area_complete) then
        set skip_tech_area := TRUE
        // Debug output
        call Sys_Debug_Print("Research", "    - Skip " + tech_name + " (Maxed)")
      else
        // Skip if the tech area is already at the level we want
        if (tech_level >= max_level) then
          set skip_tech_area := TRUE
          // Debug output
          call Sys_Debug_Print("Research", "    - Skip " + tech_name + " (Achieved)")
        endif
      endif
    else
      set skip_tech_area := TRUE
      // Debug output
      call Sys_Debug_Print("Research", "    - Skip " + tech_name + " (Not visible)")
    endif
    // Skip if we are already spending 100%
    if (Sys_Get_Empire_Research_Total_Tech_Area_Spending_Pct(sys_long_player_ID) = 100) then
      set skip_tech_area := TRUE
      // Debug output
      call Sys_Debug_Print("Research", "    - Skip " + tech_name + " (Spending at 100%)")
    endif
  else
    set skip_tech_area := TRUE
    // Debug output
    call Sys_Debug_Print("Research", "    - Skip " + tech_name + " (Not wanted/available)")
  endif

  // Don't attempt to add tech areas that we are skipping
  if (skip_tech_area) then
    set add_tech_area := FALSE
  endif

  // Attempt to add the tech area to our research queue
  if (add_tech_area) then
    // Get our research points to spend
    set cur_spending_pts := Sys_Get_Empire_Current_Points(sys_long_Player_ID, POINT_TYPE_RESEARCH)

    // Add Tech Area if it is available for research and we have research points to spend
    if (Sys_Get_Empire_Research_Total_Tech_Area_Spending_Pct(sys_long_Player_ID) < 100) then
      // Attempt to the add the tech area to the research queue
      if Sys_Is_Empire_Research_Tech_Visible(sys_long_Player_ID, tech_id) then
        if (tech_level < max_level) then
          set pts_to_next_level := Sys_Trunc(Sys_Get_Empire_Research_Tech_Area_Cost_For_Next_Level(sys_long_Player_ID, tech_id) - Sys_Get_Empire_Research_Tech_Area_Accumulated_Points(sys_long_Player_ID, tech_id))
          set spending_pct := Sys_Min_Long(Get_Tech_Group_Spending_Pct(tech_id), 2 + Sys_Trunc(pts_to_next_level / cur_spending_pts * 100))
          set pts_to_spend := Sys_Trunc(spending_pct / 100 * cur_spending_pts)
          // Will we gain a tech level for this tech area next turn?
          if (pts_to_spend >= pts_to_next_level) then
            set tech_level_complete := TRUE
            // For some tech areas important to ship upgrades, increase our design upgrade modifier
            if (Sys_Pos_String("Engines", tech_name) > 0) or (Sys_Pos_String("Weapons", tech_name) > 0) then
              set lng_AI_Design_Upgrade_Modifier := lng_AI_Design_Upgrade_Modifier + 3
            endif
            if (Sys_Pos_String("Armor", tech_name) > 0) or (Sys_Pos_String("Shields", tech_name) > 0) or (Sys_Pos_String("Mounts", tech_name) > 0) or (Sys_Pos_String("Sensors", tech_name) > 0) or (Sys_Pos_String("Defense", tech_name) > 0) then
              set lng_AI_Design_Upgrade_Modifier := lng_AI_Design_Upgrade_Modifier + 1
            endif
            if (Sys_Pos_String("Crystalline", tech_name) > 0) or (Sys_Pos_String("Interdimensional", tech_name) > 0) or (Sys_Pos_String("Organic", tech_name) > 0) or (Sys_Pos_String("Psychic", tech_name) > 0) or (Sys_Pos_String("Religious", tech_name) > 0) or (Sys_Pos_String("Temporal", tech_name) > 0) then
              set lng_AI_Design_Upgrade_Modifier := lng_AI_Design_Upgrade_Modifier + 1
            endif
          endif
          // Only spend the points on this item to get to the next level
          if (spending_pct > 0) then
            set tech_area_added := Sys_Set_Empire_Research_Tech_Area_Spending_Pct(sys_long_Player_ID, tech_id, spending_pct)
            call Set_Tech_Group_Spending_Pct(tech_id, spending_pct)
          endif
        endif
      else
        // If we do not have the tech area, attempt to add the perquisite tech area instead
        set add_tech_area := Get_Required_Techs_For_Tech(tech_name, base_tech_name, base_tech_level)
        set base_tech_level := Sys_Min_Long(lng_Research_Age_Max_Level, base_tech_level)

        if (add_tech_area) and (base_tech_level > 0) then
          set tech_id := Sys_Get_Tech_ID(base_tech_name)
          if Sys_Is_Empire_Research_Tech_Visible(sys_long_Player_ID, tech_id) then
            set pts_to_next_level := Sys_Trunc(Sys_Get_Empire_Research_Tech_Area_Cost_For_Next_Level(sys_long_Player_ID, tech_id) - Sys_Get_Empire_Research_Tech_Area_Accumulated_Points(sys_long_Player_ID, tech_id))
            if (Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, tech_id) <= base_tech_level) then
              set spending_pct := Sys_Min_Long(Get_Tech_Group_Spending_Pct(tech_id), 2 + Sys_Trunc(pts_to_next_level / cur_spending_pts * 100))
              if (spending_pct > 0) then
                set tech_area_added := Sys_Set_Empire_Research_Tech_Area_Spending_Pct(sys_long_Player_ID, tech_id, spending_pct)
                call Set_Tech_Group_Spending_Pct(tech_id, spending_pct)
              endif
            endif
          endif
        endif
      endif
    endif
  endif

  // Debug output
  if (tech_area_added) then
    set debug_str := Sys_Convert_Long_To_String(tech_level + 1) + " at " Sys_Convert_Long_To_String(spending_pct) + "%"
    call Sys_Debug_Print("Research", "    - Added " + tech_name + " level " + debug_str + " to research queue")
  else
    if (not skip_tech_area) then
      set debug_str := Sys_Convert_Long_To_String(tech_level + 1)
      call Sys_Debug_Print("Research", "    - Failed to add " + tech_name + " level " + debug_str + " to research queue")
    endif
  endif
  // Note tech areas that are completing next turn
  if (tech_level_complete) then
    call Sys_Debug_Print("Research", "    - Completing next turn")
    call Sys_Debug_Print("Research", "      - Upgrade flag = " + Sys_Convert_Long_To_String(lng_AI_Design_Upgrade_Modifier))
  endif

  return tech_area_added
end

//------------------------------------------------------------------------
// Add_Tech_Area_By_ID
//------------------------------------------------------------------------
function Add_Tech_Area_By_ID returns boolean
params
  tech_id:                   long
vars
  tech_name:                 string
  tech_level:                long
  tech_area_complete:        boolean := FALSE
  pts_to_next_level:         long
  spending_pct:              long
  cur_spending_pts:          long
begin

  // Research any remaining tech areas?
  if (Sys_Get_Empire_Research_Total_Tech_Area_Spending_Pct(sys_long_Player_ID) < 100) then
    set tech_name := Sys_Get_Tech_Area_Name(tech_id)
    set tech_level := Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, tech_id)
    set tech_area_complete := Sys_Is_Empire_Research_Tech_At_Maximum(sys_long_Player_ID, tech_id)
    set cur_spending_pts := Sys_Get_Empire_Current_Points(sys_long_Player_ID, POINT_TYPE_RESEARCH)
    // Are we at the tech's max level?
    if (not tech_area_complete) and Sys_Is_Empire_Research_Tech_Visible(sys_long_Player_ID, tech_id) then
      set pts_to_next_level := Sys_Trunc(Sys_Get_Empire_Research_Tech_Area_Cost_For_Next_Level(sys_long_Player_ID, tech_id) - Sys_Get_Empire_Research_Tech_Area_Accumulated_Points(sys_long_Player_ID, tech_id))
      set spending_pct := Sys_Min_Long(Sys_Trunc(pts_to_next_level / cur_spending_pts * 100) + 1, 100)
      // Only spend the points on this item to get to the next level
      if (spending_pct > 0) then
        call Sys_Set_Empire_Research_Tech_Area_Spending_Pct(sys_long_Player_ID, tech_id, spending_pct)
        // Debug output
        call Sys_Debug_Print("Research", "    - Added " + tech_name + " at " + Sys_Convert_Long_To_String(spending_pct) + "%")
      endif
    endif
  endif

  return TRUE
end

//------------------------------------------------------------------------
// Get_Tech_Group_Spending_Pct
//------------------------------------------------------------------------
function Get_Tech_Group_Spending_Pct returns long
params
  tech_id:                   long
vars
  tech_group:                string
  list_pos:                  long
  spending_pct:              long := 0
begin 

  // Get the tech group that the tech area belongs to
  set tech_group := Sys_Get_Tech_Area_Group(tech_id)
  set list_pos := lst_Research_Spending_Group_Name.indexof(tech_group)

  // Set our research spending for this tech based on our group spending
  if (list_pos > 0) then
    set spending_pct := lst_Research_Spending_For_Group.get(list_pos)
  endif

  return spending_pct
end

//------------------------------------------------------------------------
// Set_Tech_Group_Spending_Pct
//------------------------------------------------------------------------
function Set_Tech_Group_Spending_Pct returns boolean
params
  tech_id:                   long
  spending_amt:              long
vars
  tech_group:                string
  list_pos:                  long
  spending_pct:              long := 0
begin 

  // Get the tech group that the tech area belongs to
  set tech_group := Sys_Get_Tech_Area_Group(tech_id)

  // Set group spending
  set list_pos := lst_Research_Spending_Group_Name.indexof(tech_group)

  if (list_pos > 0) then
    set spending_pct := lst_Research_Spending_For_Group.get(list_pos)
    set spending_pct := spending_pct - spending_amt
    // Set the spending to 0
    if (spending_pct < 0) then
      set spending_pct := 0
    endif
    call lst_Research_Spending_For_group.set(list_pos, spending_pct)
  endif

  return TRUE
end

//------------------------------------------------------------------------
// Get_Required_Techs_For_Tech
//------------------------------------------------------------------------
function Get_Required_Techs_For_Tech returns boolean
params
  src_tech_name:             string
  tech_name:                 string byref
  tech_level:                long byref
begin
  set tech_name := ""
  set tech_level := 0

  case (src_tech_name)
    "Civics":
      set tech_name := "Cultural Studies"
      set tech_level := 1
    "Conservation":
      set tech_name := "Cultural Studies"
      set tech_level := 1
    "Diplomacy":
      set tech_name := "Applied Political Science"
      set tech_level := 1
    "Economics":
      set tech_name := "Cultural Studies"
      set tech_level := 1
    "Education":
      set tech_name := "Cultural Studies"
      set tech_level := 1
    "Engineering":
      set tech_name := "Construction"
      set tech_level := 2
    "Environment":
      set tech_name := "Biology"
      set tech_level := 2
    "Ethics":
      set tech_name := "Cultural Studies"
      set tech_level := 1
    "Logistics":
      set tech_name := "Industry"
      set tech_level := 2
    "Military":
      set tech_name := "Advanced Military Science"
      set tech_level := 1
    "Recreation":
      set tech_name := "Cultural Studies"
      set tech_level := 1
    "Sociology":
      set tech_name := "Psychology"
      set tech_level := 1
    "Medium Ship Construction":
      set tech_name := "Construction"
      set tech_level := 2
    "Large Ship Construction":
      set tech_name := "Construction"
      set tech_level := 3
    "Baseship Construction":
      set tech_name := "Large Ship Construction"
      set tech_level := 6
    "Large Base Construction":
      set tech_name := "Construction"
      set tech_level := 3
    "Mines":
      set tech_name := "Construction"
      set tech_level := 1
    "Drones":
      set tech_name := "Computers"
      set tech_level := 1
    "Gravitational Manipulation":
      set tech_name := "Astrophysics"
      set tech_level := 3
    "Computers":
      set tech_name := "Industry"
      set tech_level := 2
    "Contra-Terrene Engines":
      set tech_name := "Ion Engines"
      set tech_level := 3
    "Jacketed-Photon Engines":
      set tech_name := "Contra-Terrene Engines"
      set tech_level := 3
    "Quantum Engines":
      set tech_name := "Jacketed-Photon Engines"
      set tech_level := 3
    "Stellar Harnessing":
      set tech_name := "Astrophysics"
      set tech_level := 1
    "Shields":
      set tech_name := "Physics"
      set tech_level := 2
    "Cloaking":
      set tech_name := "Physics"
      set tech_level := 4
    "Scanners":
      set tech_name := "Physics"
      set tech_level := 3
    "Defense Systems":
      set tech_name := "Military Science"
      set tech_level := 2
    "Ship Weapon Mounts":
      set tech_name := "Weapon Mounts"
      set tech_level := 1
    "Base Weapon Mounts":
      set tech_name := "Weapon Mounts"
      set tech_level := 1
    "Unit Weapon Mounts":
      set tech_name := "Weapon Mounts"
      set tech_level := 1
    "Stellar Manipulation":
      set tech_name := "Astrophysics"
      set tech_level := 5
    "Storm Manipulation":
      set tech_name := "Stellar Manipulation"
      set tech_level := 1
    "Planetary Manipulation":
      set tech_name := "Stellar Manipulation"
      set tech_level := 2
    "Warp Point Manipulation":
      set tech_name := "Stellar Manipulation"
      set tech_level := 3
    "Star Manipulation":
      set tech_name := "Stellar Manipulation"
      set tech_level := 4
    "Nebulae Manipulation":
      set tech_name := "Stellar Manipulation"
      set tech_level := 4
    "Black Hole Manipulation":
      set tech_name := "Stellar Manipulation"
      set tech_level := 5
    "Stellar Construction":
      set tech_name := "Stellar Manipulation"
      set tech_level := 6
    "Advanced Military Science":
      set tech_name := "Military Science"
      set tech_level := 3
    "Applied Political Science":
      set tech_name := "Psychology"
      set tech_level := 1
    "Medical Treatment":
      set tech_name := "Biology"
      set tech_level := 1
    "Robotics":
      set tech_name := "Construction"
      set tech_level := 3
    "Centralized Computer Systems":
      set tech_name := "Industry"
      set tech_level := 3
    "Planetary Defenses":
      set tech_name := "Shields"
      set tech_level := 5
    "Planet Utilization":
      set tech_name := "Planetary Engineering"
      set tech_level := 1
    "Resource Manipulation":
      set tech_name := "Chemistry"
      set tech_level := 3
    "Sabotage - Ships & Fleets":
      set tech_name := "Intelligence Services"
      set tech_level := 1
    "Sabotage - Planets & Colonies":
      set tech_name := "Intelligence Services"
      set tech_level := 2
    "Sabotage - Empire Wide":
      set tech_name := "Intelligence Services"
      set tech_level := 3
    "Sabotage - Political":
      set tech_name := "Intelligence Services"
      set tech_level := 4
    "Espionage - Ships & Fleets":
      set tech_name := "Intelligence Services"
      set tech_level := 1
    "Espionage - Planets & Colonies":
      set tech_name := "Intelligence Services"
      set tech_level := 2
    "Espionage - Empire Wide":
      set tech_name := "Intelligence Services"
      set tech_level := 3
    "Espionage - Political":
      set tech_name := "Intelligence Services"
      set tech_level := 4
    "Cooperative Intelligence":
      set tech_name := "Intelligence Services"
      set tech_level := 5
    "Energy Stream Weapons":
      set tech_name := "Physics"
      set tech_level := 2
    "Energy Pulse Weapons":
      set tech_name := "Physics"
      set tech_level := 2
    "Plasma Missile Weapons":
      set tech_name := "Chemistry"
      set tech_level := 2
    "Torpedo Weapons":
      set tech_name := "Military Science"
      set tech_level := 3
    "High-Energy Discharge Weapons":
      set tech_name := "Physics"
      set tech_level := 3
    "Phased-Energy Weapons":
      set tech_name := "Physics"
      set tech_level := 3
    "Shield Damaging Weapons":
      set tech_name := "Shields"
      set tech_level := 1
    "Tractor\Repulser Weapons":
      set tech_name := "Astrophysics"
      set tech_level := 2
    "Weapon Overloading Weapons":
      set tech_name := "Astrophysics"
      set tech_level := 2
    "Engine Overloading Weapons":
      set tech_name := "Ion Engines"
      set tech_level := 3
    "Gravitational Weapons":
      set tech_name := "Astrophysics"
      set tech_level := 3
    "Warp Weapons":
      set tech_name := "Astrophysics"
      set tech_level := 4
    "Computer Combat":
      set tech_name := "Computers"
      set tech_level := 3
    "Null-Space Weapons":
      set tech_name := "Astrophysics"
      set tech_level := 3
    "Ship Capture":
      set tech_name := "Military Science"
      set tech_level := 2
    "Biological Weapons":
      set tech_name := "Biology"
      set tech_level := 2
    "Massive Shield Depleting Weapons":
      set tech_name := "Xenoarchaeology"
      set tech_level := 1
    "Massive Engine Destroying Weapons":
      set tech_name := "Xenoarchaeology"
      set tech_level := 1
    "Power Leech":
      set tech_name := "Xenoarchaeology"
      set tech_level := 1
    "Shield Implosion":
      set tech_name := "Xenoarchaeology"
      set tech_level := 1
    "Massive Planetary Shielding":
      set tech_name := "Xenoarchaeology"
      set tech_level := 1
    "Neural Computer Interface":
      set tech_name := "Xenoarchaeology"
      set tech_level := 1
  endcase

  return (tech_level > 0)
end

//------------------------------------------------------------------------
// Give_Research_Boost
//------------------------------------------------------------------------
function Give_Research_Boost returns boolean
vars
  tech_count:                long
  tech_index:                long
  tech_id:                   long
  tech_name:                 string
  tech_level:                long
  research_pts:              long
  research_pct:              long
  research_spend:            real
  research_cost:             real
  research_accumulated:      real
  research_remaining:        real
  research_adjustment:       real
begin

  // Note our research points
  set research_pts := Sys_Get_Empire_Current_Points(sys_long_Player_ID, POINT_TYPE_RESEARCH)

  // Accelerate research in critical areas
  set tech_count := Sys_Get_Tech_Area_Count()
  // Consider providing a boost
  for tech_index := 1 to tech_count do
    set tech_id := Sys_Get_Tech_By_Index(tech_index)
    set tech_name := Sys_Get_Tech_Area_Name(tech_id)
    set tech_level := Sys_Get_Empire_Research_Tech_Level(sys_long_Player_ID, tech_id)
    // Get tech area research details
    set research_pct := Sys_Get_Empire_Research_Tech_Area_Spending_Pct(sys_long_Player_ID, tech_id)
    set research_cost := Sys_Get_Empire_Research_Tech_Area_Cost_For_Next_Level(sys_long_Player_ID, tech_id)
    set research_accumulated := Sys_Get_Empire_Research_Tech_Area_Accumulated_Points(sys_long_Player_ID, tech_id)
    set research_spend := research_pts * research_pct / 100
    set research_remaining := research_cost - research_accumulated - research_spend
    set research_adjustment := 0.0
    // Considering granting colonization tech areas even if they are not being actively researched
    if (research_spend = 0) then
      if (tech_name = "Rock Planet Colonization") or (tech_name = "Ice Planet Colonization") or (tech_name = "Gas Giant Colonization") then
        if (tech_level = 0) then
          // 10% chance for player to get colonization area
          if (Sys_Get_Random_Long(1, 10) = 1) then
            set research_adjustment := research_remaining + 1
          endif
        endif
      endif
    else
      // Complete 25%, 33% or 50% of the tech area
      set research_adjustment := (research_remaining / Sys_Get_Random_Long(2, 4))
    endif
    // Adjust our research points if we have had a setback or breakthrough
    if (research_adjustment > 0) then
      call Sys_Change_Empire_Research_Tech_Area_Accomplished_Amount(sys_long_Player_ID, tech_id, research_adjustment)
      // Debug output
      call Sys_Debug_Print("Research", "  - Added " + Sys_Convert_Real_To_String(research_adjustment) + " RPs towards " + tech_name + " Level (" + Sys_Convert_Long_To_String((tech_level + 1)) + ")" + "; (" + Sys_Convert_Real_To_String(research_accumulated) + "/" Sys_Convert_Real_To_String(research_spend) + "/" + Sys_Convert_Real_To_String(research_cost) + ")")
    endif
  endfor

  return true
end

//------------------------------------------------------------------------